import Vue from 'vue'

import App from './App'
import store from './store'
import router from './router'

// * 引入全局样式
import '@/assets/styles/index.scss'

// * 引入字体样式
import '@/assets/fonts/DS-DIGI/DS-DIGI.css'

// * element ui plugins
import '@/plugins/element-ui'
import '@/plugins/vue-quill-editor'


// * icon
import '@/icons'
// * permission control
import '@/permission'


import permission from './directive/permission'

// * 全局组件挂载
import '@/components'

import { getDicts } from '@/api/system/dict/data'
import { getConfigKey } from '@/api/system/config'
import {
  parseTime,
  resetForm,
  addDateRange,
  selectDictLabel,
  selectDictLabels,
  selectDictValue,
  download,
  downloadExcel,
  handleTree,
  formatMoney,
  valueToPercent,
  percentToValue,
  commafyback,
  downloadFile,
} from '@/utils/ntschy'

import esriLoader from 'esri-loader'

// 资源前缀
const GIS_RESOURCE_BASE_URL = process.env['VUE_APP_GIS_RESOURCE_BASE_URL']

// 请求前缀
const VUE_APP_BASE_API = process.env['VUE_APP_BASE_API']

// esriLoader.loadCss(
//   `${GIS_RESOURCE_BASE_URL}/arcgis_js_api/library/3.19/3.19/dijit/themes/tundra/tundra.css`
//   // 'https://js.arcgis.com/3.19/dijit/themes/tundra/tundra.css'
// )

// esriLoader.loadCss(
//   `${GIS_RESOURCE_BASE_URL}/arcgis_js_api/library/3.19/3.19/esri/css/esri.css`
//   // 'https://js.arcgis.com/3.19/esri/css/esri.css'
// )

// esriLoader.loadScript({
//   dojoConfig: {
//     async: true,
//     packages: [
//       {
//         location: '/static',
//         name: 'static',
//       },
//     ],
//   },
//   url: `${GIS_RESOURCE_BASE_URL}/arcgis_js_api/library/3.19/3.19/init.js`,
//   // url: 'https://js.arcgis.com/3.19/init.js',
// })

// bus 消息站
Vue.prototype.$bus = new Vue()

// * 注册全局过滤器
Vue.filter('parseTime', parseTime)

// 全局方法挂载
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.selectDictValue = selectDictValue

// Vue.prototype.download = download
Vue.prototype.downloadExcel = downloadExcel
Vue.prototype.handleTree = handleTree
Vue.prototype.valueToPercent = valueToPercent
Vue.prototype.percentToValue = percentToValue
Vue.prototype.commafyback = commafyback
Vue.prototype.formatMoney = formatMoney
Vue.prototype.downloadFile = downloadFile
Vue.prototype.imgPrefix = VUE_APP_BASE_API

Vue.prototype.msgSuccess = function (msg) {
  this.$message({ showClose: true, message: msg, type: 'success' })
}

Vue.prototype.msgWarning = function (msg) {
  this.$message({ showClose: true, message: msg, type: 'warning' })
}

Vue.prototype.msgError = function (msg) {
  this.$message({ showClose: true, message: msg, type: 'error' })
}

Vue.prototype.msgInfo = function (msg) {
  this.$message.info(msg)
}



Vue.use(permission)


// ! 路由处理
import './utils/route'

// ! 数组扩展
import './utils/array'

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: (h) => h(App),
})
